/*
 * @Author: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @Date: 2022-10-16 19:07:44
 * @LastEditors: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @LastEditTime: 2022-10-21 18:48:19
 * @FilePath: \实训二——宏业找房\app\demo\src\Route\index.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEnt
 */
import React, { lazy } from 'react'
import { Navigate } from 'react-router-dom';
const Layout =lazy(()=>import('../page/Layout/index.jsx'));
const Login = lazy(() => import('../page/Login/index.jsx'));
const Housing = lazy(() => import('../page/Housing/index.jsx'));
const Live = lazy(() => import('../page/Live/index.jsx'));
const Bulk = lazy(() => import('../page/Bulk/index.jsx'));
const Audit = lazy(() => import('../page/Audit/index.jsx'));
const Order = lazy(() => import('../page/Order/index.jsx'));
const Information = lazy(() => import('../page/Information/index.jsx'));
const Agent = lazy(() => import('../page/Agent/index.jsx'));
const LiveHome = lazy(() => import('../page/LiveHome/index.jsx'));


// 路由拦截
const ProviteRoute = ({ children }) => {
    const token = localStorage.getItem('token')
    if (!token) {
        return <Navigate to="/"></Navigate>;
    }
    return children
}

export const RouterList=[
    {
        path:'/',
        redirect:'/',
        element:<Login/>
    },
    {
        path:'/detail',
        element: <LiveHome/>
    },
    {
        path:'/layout',
        element:<Layout />,
        children:[
            {
                path:'/layout/housing',
                element: <ProviteRoute> <Housing /></ProviteRoute>,
                
            },
            {
                path: '/layout/live',
                element: <Live />,
            },
            {
                path: '/layout/bulk',
                element: <Bulk />,
            },
            {
                path: '/layout/audit',
                element: <Audit />,
            },
            {
                path: '/layout/order',
                element: <Order />,
            },
            {
                path: '/layout/information',
                element: <Information />,
            },
            {
                path: '/layout/agent',
                element: <Agent />,
            },
        ]
    }
]
